<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>企业员工管理-工资查询</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" href="static/css/font.css">
  <link rel="stylesheet" href="static/css/xadmin.css">
  <script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
  <script type="text/javascript" src="static/lib/layui/layui.js"></script>
  <script type="text/javascript" src="static/js/xadmin.js"></script>

</head>

<body class="layui-anim layui-anim-up">

<div class="x-nav">
      <span class="layui-breadcrumb">
        <a >首页</a>
        <a >工资管理</a>
        <a>
          <cite>工资查询</cite></a>
      </span>
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" id="container">
  <div class="demoTable">
    员工工号：
    <div class="layui-inline">
      <input class="layui-input" name="account" id="eAccount" autocomplete="off">
    </div>&nbsp&nbsp&nbsp
    部门：
    <div class="layui-inline">
      <div class="layui-input-inline">
        <select name="dep" id="dId" style="height: 38px;" lay-verify="required" lay-search="">
          <option value="">--全部--</option>
        </select>
      </div>
    </div>&nbsp;&nbsp;&nbsp;&nbsp;
    月份：
    <div class="layui-inline">
      <input name="d" id="date" lay-verify="date" autocomplete="off" class="layui-input" type="text" readonly>
    </div>&nbsp&nbsp&nbsp
    <button class="layui-btn" data-type="reload">搜索</button>
    <button class="layui-btn" id="download" >导出工资单</button>
  </div>

</div>



<div style="text-align: center">
  <table class="layui-table" lay-data="{height: 'full', cellMinWidth:80, url:'selectSalaryByEaccountDIdDate.do',even: true, page:true,initSort: {field: 'sTime', type: 'desc'}, id:'idTest'}" lay-filter="demo">
    <thead>
    <tr>
      <th lay-data="{field:'sTime',sort: true ,width:83, fixed: true,align: 'center'}" rowspan="2">月份</th>
      <th lay-data="{field:'eName',fixed: true, templet: '<span>{{d.employee.eName}}</span>',minWidth:80,align: 'center'}"
          rowspan="2">姓名
      </th>
      <th lay-data="{minWidth:100,align: 'center'}" colspan="2">员工信息</th>
      <th lay-data="{field:'shouldPay', width:86, align: 'center'}" rowspan="2">应发工资</th>
      <th lay-data="{field:'basePay', width:86, align: 'center'}" rowspan="2">基本工资</th>
      <th lay-data="{field:'rissuePay', width:86, align: 'center'}" rowspan="2">其他工资</th>
      <th lay-data="{minWidth:100,align: 'center'}" colspan="4">补贴</th>
      <th lay-data="{minWidth:100,align: 'center'}" colspan="4">奖金</th>
      <th lay-data="{minWidth:100,align: 'center'}" colspan="6">五险一金</th>
      <th lay-data="{minWidth:100,align: 'center'}" colspan="5">工资扣额</th>

      <th lay-data="{field:'actualPay', width:96,sort: true , fixed: 'right',align: 'center'}" rowspan="2">实发工资</th>
      <th lay-data="{field:'sState', templet: '#checkboxTpl',unresize: true ,width:100, fixed: 'right',align: 'center'}" rowspan="2">发放</th>
      <!--<th lay-data="{fixed: 'right', width:130, align:'center', toolbar: '#barDemo'}" rowspan="2"></th>-->
    </tr>
    <tr>
      <th lay-data="{field:'eAccount', templet: '<span>{{d.employee.eAccount}}</span>',minWidth:95,align: 'center'}"
          rowspan="2">工号
      </th>
      <th lay-data="{field:'dName', templet: '<span>{{d.department.dName}}</span>',minWidth:80,align: 'center'}"
          rowspan="2">部门
      </th>
      <th lay-data="{field:'foodPay', minWidth:60,align: 'center'}">餐饮</th>
      <th lay-data="{field:'postPay', minWidth:60,align: 'center'}">岗位</th>
      <th lay-data="{field:'trafficPay', minWidth:60,align: 'center'}">交通</th>
      <th lay-data="{field:'businessTravelPay', minWidth:60,align: 'center'}">出差</th>

      <th lay-data="{field:'workingYearPay', minWidth:60,align: 'center'}">工龄</th>
      <th lay-data="{field:'rankPay', minWidth:60,align: 'center'}">职称</th>
      <th lay-data="{field:'overtimePay', minWidth:70,align: 'center'}">加班</th>
      <th lay-data="{field:'fullAttendancePay', minWidth:60,align: 'center'}">全勤</th>

      <th lay-data="{field:'persionPay', minWidth:70,align: 'center'}">养老</th>
      <th lay-data="{field:'medicalPay',  minWidth:70,align: 'center'}">医疗</th>
      <th lay-data="{field:'unemploymentPay', minWidth:60,align: 'center'}">失业</th>
      <th lay-data="{field:'injuryPay', minWidth:60,align: 'center'}">工伤</th>
      <th lay-data="{field:'birthPay', minWidth:60,align: 'center'}">生育</th>
      <th lay-data="{field:'housingPay', minWidth:100,align: 'center'}">住房公积金</th>
      <th lay-data="{field:'latePay',  minWidth:60,align: 'center'}">迟到</th>
      <th lay-data="{field:'earlyPay', minWidth:60,align: 'center'}">早退</th>
      <th lay-data="{field:'sickPay', minWidth:60,align: 'center'}">病假</th>
      <th lay-data="{field:'thingPay', minWidth:60,align: 'center'}">事假</th>
      <th lay-data="{field:'individualIncomeTax', minWidth:100,align: 'center'}">个人所得税</th>
    </tr>
    </thead>
  </table>
</div>

</div>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="checkboxTpl">
  <!-- 这里的 checked 的状态只是演示 -->
  <input type="checkbox" disabled="" name="lock" value="{{d.sState}}" title="是" lay-filter="lockDemo" {{ d.sState== 1 ?'checked'
  : '' }}>
</script>
<script>

    window.onload = function () {
        //加载部门下拉搜索框
        var dId = $("#dId");
        $.ajax({
            url:'department/findSelective.do?page=1&limit=999', //分页限制为999条，就是全部
            dataType:'json',
            type:'post',
            success:function(result){
                // console.log(result);
                $.each(result.data,function(index,item){
                    // console.log(index + "&" + item.dId);
                    dId.append("<option value="+item.dId+">"+item.dName+"</option>");// 下拉菜单里添加元素
                })
            }
        });
    }

    layui.use(['form', 'layedit', 'laydate','table'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate
            ,table = layui.table;

        //年月范围
        laydate.render({
            elem: '#date'
            ,type: 'month'
        });

        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('确定要删除吗', function(index){
                    // console.log(data.monthlyAttendance);
                    $.ajax({
                        type:'post',
                        url:'monthlyattendance/deleteByPrimaryKey.do',
                        data: {"id":data.monthlyAttendance.maId},
                        dataType:'json',
                        success:function(data){
                            // alert("success");
                        }

                    });
                    obj.del();
                    layer.close(index);
                    location.reload();
                });
            } else if(obj.event === 'edit'){
                // layer.alert('编辑行：<br>'+ JSON.stringify(data));
                x_admin_show('编辑','toPage.do?url=admin/monthlyattendance-edit.html', 850,400);

            }
        });

        var $ = layui.$, active = {

            reload: function(){
                var eAccount = $('#eAccount');
                var dId = $('#dId');
                var date = $('#date');
                // alert("asd");
                // console.log(eAccount.val()+" "+dId.val()+" "+date.val());
                // 执行重载
                table.reload('idTest', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        eAccount: eAccount.val(),
                        dId: dId.val(),
                        sTime: date.val()
                    }
                });
            }
        };
        function download(){
            var eAccount = $('#eAccount').val();
            var dId = $('#dId').val();
            var date = $('#date').val();
            window.location.href="downloadExcel.do?eAccount="+eAccount+"&dId="+dId+"&sTime="+date
        }
        $('#download').on('click',function () {
            download();
        })
    $('.demoTable .layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
    });

</script>

</body>

</html>